home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / rpc / rpcCltStat.c < prev    next >
C/C++ Source or Header  |  1990-10-18  |  8KB  |  266 lines

  1. /*
  2.  * rpcCltStat.c --
  3.  *      Manipulation and printing of the statistics taken on the client
  4.  *      side of the RPC system.  The statistics are kept as simple event
  5.  *      counts.  The counts are incremented in unsynchronized sections of
  6.  *      code.  They are reset and printed out with a pair of synchronized
  7.  *      routines.  Clients of the RPC system can use these to trace long
  8.  *      term RPC exersices.  At any time an RPC client can declare itself
  9.  *      as entering the RPC system for tracing purposes.  Any number of
  10.  *      processes can enter the system for tracing.  After the last
  11.  *      process has left the tracing system the statistics are printed on
  12.  *      the console and then reset.  (There should be a routine that
  13.  *      forces a printout of the statistics... If one process messes up
  14.  *      and doesn't leave then the stats won't get printed.)
  15.  *
  16.  * Copyright (C) 1985 Regents of the University of California
  17.  * All rights reserved.
  18.  */
  19.  
  20. #ifndef lint
  21. static char rcsid[] = "$Header: /sprite/src/kernel/rpc/RCS/rpcCltStat.c,v 9.4 90/10/18 13:56:57 kupfer Exp $ SPRITE (Berkeley)";
  22. #endif /* not lint */
  23.  
  24.  
  25. #include <sprite.h>
  26. #include <stdio.h>
  27. #include <bstring.h>
  28. #include <sync.h>
  29. #include <rpcCltStat.h>
  30. #include <user/rpc.h>
  31. #include <rpcServer.h>
  32. #include <rpc.h>
  33. #include <rpcClient.h>
  34.  
  35. /*
  36.  * Stats are taken during RPC to help make sure all parts
  37.  * of the algorithm are exersiced and to monitor the condition
  38.  * of the system.
  39.  * Two sets of statistics are kept, a total and a triptik.
  40.  */
  41. Rpc_CltStat rpcTotalCltStat;
  42. Rpc_CltStat rpcCltStat;
  43. static int numStats = sizeof(Rpc_CltStat) / sizeof(int);
  44.  
  45. #ifdef notdef
  46. /*
  47.  * This is the monitored data whichs keeps track of how many processes
  48.  * are using the RPC system.
  49.  */
  50. static int numRpcProcesses;
  51.  
  52. /*
  53.  * The entering and leaving monitored.
  54.  */
  55. static Sync_Lock rpcTraceLock = Sync_LockInitStatic("Rpc:rpcTraceLock");
  56. #define LOCKPTR (&rpcTraceLock)
  57. #endif /* notdef */
  58.  
  59.  
  60.  
  61. /*
  62.  *----------------------------------------------------------------------
  63.  *
  64.  * Rpc_EnterProcess --
  65.  *
  66.  *      Note that a process is entering the RPC system for tracing.  This
  67.  *      call should be followed later by a call to Rpc_LeaveProcess.
  68.  *      These two procedures are used to start, stop, and print statistics
  69.  *      on the RPC system.  After a process enters, the system waits until
  70.  *      everyone that enters has left and then prints out the accumulated
  71.  *      statistics for the period when the first process registered and
  72.  *      the last process left.
  73.  *
  74.  * Results:
  75.  *    None.
  76.  *
  77.  * Side effects:
  78.  *    Increment the number of processes in the RPC system, initialize
  79.  *    the statistics structre at the entry of the first process.
  80.  *
  81.  *----------------------------------------------------------------------
  82.  */
  83. #ifdef notdef
  84. ENTRY void
  85. Rpc_EnterProcess()
  86. {
  87.     LOCK_MONITOR;
  88.  
  89.  
  90.     numRpcProcesses++;
  91.     if (numRpcProcesses == 1) {
  92.     RpcResetCltStat();
  93.     }
  94.  
  95.     UNLOCK_MONITOR;
  96. }
  97. #endif /* notdef */
  98.  
  99. /*
  100.  *----------------------------------------------------------------------
  101.  *
  102.  * RpcResetCltStat --
  103.  *
  104.  *      Accumulate the client side stats in the Totals struct and
  105.  *      reset the current counters.  This is not synchronized with
  106.  *      interrupt time code so errors may occur.
  107.  *
  108.  * Results:
  109.  *    None.
  110.  *
  111.  * Side effects:
  112.  *    Increment the counters in the Total struct and reset the
  113.  *      current counters to zero.
  114.  *----------------------------------------------------------------------
  115.  */
  116. void
  117. RpcResetCltStat()
  118.     /*
  119.      * Could be parameterized and combined with RpcResetSrvStat...
  120.      */
  121. {
  122.     register int *totalIntPtr;
  123.     register int *deltaIntPtr;
  124.     register int index;
  125.     /*
  126.      * Add the current statistics to the totals and then
  127.      * reset the counters.  The statistic structs are cast
  128.      * into integer arrays to make this easier to maintain.
  129.      */
  130.     totalIntPtr = (int *)&rpcTotalCltStat;
  131.     deltaIntPtr = (int *)&rpcCltStat;
  132.     for (index = 0; index<numStats ; index++) {
  133.         *totalIntPtr += *deltaIntPtr;
  134.         totalIntPtr++;
  135.         deltaIntPtr++;
  136.     }
  137.     bzero((Address)&rpcCltStat, sizeof(Rpc_CltStat));
  138. }
  139.  
  140. /*
  141.  *----------------------------------------------------------------------
  142.  *
  143.  * Rpc_LeaveProcess --
  144.  *
  145.  *    Note that a process has left the RPC system for tracing.
  146.  *    After the last process leaves the RPC system this prints out the
  147.  *    statistics that have accrued so far.
  148.  *
  149.  * Results:
  150.  *    Maybe to the printfs.
  151.  *
  152.  * Side effects:
  153.  *    Decrement the number of processes in the RPC system.
  154.  *
  155.  *----------------------------------------------------------------------
  156.  */
  157. #ifdef notdef
  158. ENTRY void
  159. Rpc_LeaveProcess()
  160. {
  161.     LOCK_MONITOR;
  162.  
  163.     numRpcProcesses--;
  164.     if (numRpcProcesses <= 0) {
  165.     numRpcProcesses = 0;
  166.  
  167.     Rpc_PrintCltStat();
  168.  
  169.     }
  170.  
  171.     UNLOCK_MONITOR;
  172. }
  173. #endif /* notdef */
  174.  
  175. /*
  176.  *----------------------------------------------------------------------
  177.  *
  178.  * Rpc_PrintCltStat --
  179.  *
  180.  *    Print the client RPC statistics structure.
  181.  *
  182.  * Results:
  183.  *    None.
  184.  *
  185.  * Side effects:
  186.  *    Do the prints.
  187.  *
  188.  *----------------------------------------------------------------------
  189.  */
  190. void
  191. Rpc_PrintCltStat()
  192. {
  193.     printf("Rpc Statistics\n");
  194.     printf("toClient   = %5d ", rpcCltStat.toClient);
  195.     printf("badChannel  = %4d ", rpcCltStat.badChannel);
  196.     printf("chanBusy    = %4d ", rpcCltStat.chanBusy);
  197.     printf("badId       = %4d ", rpcCltStat.badId);
  198.     printf("\n");
  199.     printf("requests   = %5d ", rpcCltStat.requests);
  200.     printf("replies    = %5d ", rpcCltStat.replies);
  201.     printf("acks        = %4d ", rpcCltStat.acks);
  202.     printf("recvPartial = %4d ", rpcCltStat.recvPartial);
  203.     printf("\n");
  204.     printf("nacks       = %4d ", rpcCltStat.nacks);
  205.     printf("reNacks    = %4d ", rpcCltStat.reNacks);
  206.     printf("maxNacks    = %4d ", rpcCltStat.maxNacks);
  207.     printf("timeouts    = %4d ", rpcCltStat.timeouts);
  208.     printf("\n");
  209.     printf("aborts      = %4d ", rpcCltStat.aborts);
  210.     printf("resends     = %4d ", rpcCltStat.resends);
  211.     printf("sentPartial = %4d ", rpcCltStat.sentPartial);
  212.     printf("errors      = %d(%d)", rpcCltStat.errors,
  213.                        rpcCltStat.nullErrors);
  214.     printf("\n");
  215.     printf("dupFrag     = %4d ", rpcCltStat.dupFrag);
  216.     printf("close       = %4d ", rpcCltStat.close);
  217.     printf("oldInputs   = %4d ", rpcCltStat.oldInputs);
  218.     printf("badInputs   = %4d ", rpcCltStat.oldInputs);
  219.     printf("\n");
  220.     printf("tooManyAcks = %4d ", rpcCltStat.tooManyAcks);
  221.     printf("chanHits   = %5d ", rpcCltStat.chanHits);
  222.     printf("chanNew     = %4d ", rpcCltStat.chanNew);
  223.     printf("chanReuse   = %4d ", rpcCltStat.chanReuse);
  224.     printf("\n");
  225.     printf("newTrouble  = %4d ", rpcCltStat.newTrouble);
  226.     printf("moreTrouble = %4d ", rpcCltStat.moreTrouble);
  227.     printf("endTrouble  = %4d ", rpcCltStat.newTrouble);
  228.     printf("noMark      = %4d ", rpcCltStat.noMark);
  229.     printf("\n");
  230.     printf("nackChanWait= %4d ", rpcCltStat.nackChanWait);
  231.     printf("chanWaits   = %4d ", rpcCltStat.chanWaits);
  232.     printf("chanBroads  = %4d ", rpcCltStat.chanBroads);
  233.     printf("paramOverrun = %3d ", rpcCltStat.paramOverrun);
  234.     printf("\n");
  235.     printf("dataOverrun = %4d ", rpcCltStat.dataOverrun);
  236.     printf("shorts      = %4d ", rpcCltStat.shorts);
  237.     printf("longs       = %4d ", rpcCltStat.longs);
  238.     printf("\n");
  239. }
  240.  
  241. /*
  242.  *----------------------------------------------------------------------
  243.  *
  244.  * Rpc_PrintCallCount --
  245.  *
  246.  *    Print the RPC call counts.
  247.  *
  248.  * Results:
  249.  *    None.
  250.  *
  251.  * Side effects:
  252.  *    Do the prints.
  253.  *
  254.  *----------------------------------------------------------------------
  255.  */
  256. void
  257. Rpc_PrintCallCount()
  258. {
  259.     register int call;
  260.  
  261.     printf("Rpc Client Calls\n");
  262.     for (call=0 ; call<=RPC_LAST_COMMAND ; call++) {
  263.     printf("%-15s %8d\n", rpcService[call].name, rpcClientCalls[call]);
  264.     }
  265. }
  266.